<template>
  <div class="app-container">
    <div class="block">
      <el-row>
        <el-col :span="24">
          <el-dropdown @command="handleCommand">
            <el-button type="primary">
              {{buttonText}}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="1">审核通过</el-dropdown-item>
              <el-dropdown-item command="0">审核不通过</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </div>

    <el-table
      :data="list"
      v-loading="listLoading"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
      @current-change="handleCurrentChange"
    >
      <el-table-column label="名称">
        <template slot-scope="scope">{{scope.row.name}}</template>
      </el-table-column>
      <el-table-column label="小图" width="80">
        <template slot-scope="scope">
          <img
            :src=" scope.row.pic==null ?'' :  apiUrl+ '/file/getImgStream?idFile=' +scope.row.pic"
            style="width:50px;"
          />
        </template>
      </el-table-column>

      <el-table-column label="类别" width="100">
        <template slot-scope="scope">{{ scope.row.category == null ? "" : scope.row.category.name}}</template>
      </el-table-column>
      <el-table-column label="产品简介" width="360">
        <template slot-scope="scope">{{scope.row.descript}}</template>
      </el-table-column>
      <el-table-column label="价格">
        <template slot-scope="scope">{{(scope.row.price / 100).toFixed(2)}}</template>
      </el-table-column>
      <el-table-column label="上架">
        <template slot-scope="scope">
          <el-switch v-model="scope.row.isOnSale" @change="changeIsOnSale(scope.row)"></el-switch>
        </template>
      </el-table-column>
      <el-table-column label="库存">
        <template slot-scope="scope">{{scope.row.stock}}</template>
      </el-table-column>
      <el-table-column label="核销比例%">
        <template slot-scope="scope">{{scope.row.writeOffRate}}</template>
      </el-table-column>
      <el-table-column label="是否新品推荐">
        <template slot-scope="scope">
          <el-tag type="success" v-show="scope.row.isNew">是</el-tag>
          <el-tag type="warning" v-show="!scope.row.isNew">否</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="是否人气商品">
        <template slot-scope="scope">
          <el-tag type="success" v-show="scope.row.isHot">是</el-tag>
          <el-tag type="warning" v-show="!scope.row.isHot">否</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="是否审核">
        <template slot-scope="scope">
          <el-switch v-model="scope.row.isAudit" @change="changeIsAudit(scope.row)"></el-switch>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      background
      layout="total, sizes, prev, pager, next, jumper"
      :page-sizes="[10, 20, 50, 100,500]"
      :page-size="listQuery.limit"
      :total="total"
      :current-page.sync="listQuery.page"
      @size-change="changeSize"
      @current-change="fetchPage"
      @prev-click="fetchPrev"
      @next-click="fetchNext"
    ></el-pagination>
  </div>
</template>

<script src="./approval.js"></script>


<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
</style>

